package com.tuliyou.dto;
import com.tuliyou.entity.UserFavorite;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserFavoriteDTO {
    /**
     * 收藏记录ID
     */
    private Long id;

    /**
     * 用户ID
     */
    private Long userId;

    /**
     * 院校/专业代码
     */
    private String code;

    /**
     * 收藏类型（UNIVERSITY/MAJOR）
     */
    private String favoriteType;

    /**
     * 创建时间
     */
    private LocalDateTime createdAt;

    public static UserFavoriteDTO fromUserFavorite(UserFavorite userFavorite) {
        if (userFavorite == null)
            return null;
        UserFavoriteDTO userFavoriteDTO = new UserFavoriteDTO(
                userFavorite.getId(),
                userFavorite.getUserId(),
                userFavorite.getCode(),
                userFavorite.getFavoriteType(),
                userFavorite.getCreatedAt()
        );
        return userFavoriteDTO;
    }
}